import request from '@/sheep/request';

export default {
  // 订单详情
  detail: (orderId) =>
    request({
      url: '/h5/order/orderDetail',
      params: orderId,
      method: 'GET',
    }),
  // 订单操作历史
  orderLog: (data) =>
      request({
        url: `/h5/oms/orderOperateHistory/list`,
        data: data,
        method: 'POST',
      }),
  // 订单详情
  expressDetail: (orderId) =>
      request({
        url: '/h5/order/expressDetail',
        params: orderId,
        method: 'GET',
    }),
  // 包裹在库订单
  storageOrder: (expressId) =>
    request({
        url: '/h5/express/storageOrder/' + expressId,
        method: 'GET',
    }),
  // 发票详情
  invoice: (id) =>
    request({
      url: 'order/invoice/' + id,
      method: 'GET',
    }),
  // 获取支付结果
  payResult: (id) =>
    request({
      url: 'order/order/' + id,
      method: 'GET',
      custom: {
        showLoading: false,
      },
    }),
  itemDetail: (id,itemId) =>
    request({
      url: 'order/order/itemDetail/'+ id + '/' + itemId,
      method: 'GET',
      custom: {
        showLoading: false,
      },
    }),
  // 订单列表
  list: (params) =>
    request({
      url: '/h5/order/page',
      method: 'GET',
      params,
      custom: {
        showLoading: false,
      },
    }),
  // 计算订单信息
  calc: (data) =>
    request({
      url: '/h5/order/addOrderCheck',
      method: 'POST',
      data,
    }),
  // 创建订单
  create: (data) =>
    request({
      url: '/h5/order/add',
      method: 'POST',
      data,
    }),
  //订单可用优惠券
  coupons: (data) =>
    request({
      url: 'order/order/coupons',
      method: 'POST',
      data,
    }),
  // 确认收货
  confirm: (id) =>
    request({
      url: '/h5/order/orderComplete',
      params: {orderId: id},
      method: 'GET'
    }),
  // 确认收货-运单
  confirmByExpress: (id) =>
      request({
        url: '/h5/express/orderComplete',
        params: {orderId: id},
        method: 'GET'
      }),
  // 查询商品是否在包裹中
  searchWareInExpress: (data) =>
      request({
        url: '/h5/express/searchWareInExpress',
        data: data,
        method: 'POST'
      }),
  // 查询包裹是否在合箱中
  searchExpressInBigExpress: (data) =>
      request({
        url: '/h5/express/searchExpressInBigExpress',
        data: data,
        method: 'POST'
      }),
  // 新建虚拟订单到包裹中
  addNewOrderToExpress: (data) =>
      request({
        url: '/h5/express/addNewOrderToExpress',
        data: data,
        method: 'POST'
      }),
  // 商品出库
  outWareInExpress: (data) =>
      request({
        url: '/h5/express/outWareInExpress',
        data: data,
        method: 'POST'
      }),
  // 包裹出库
  outExpressInBigExpress: (data) =>
      request({
        url: '/h5/express/outExpressInBigExpress',
        data: data,
        method: 'POST'
      }),
  // 包裹发货
  expressSend: (expressId) =>
      request({
        url: `/h5/express/send/${expressId}`,
        method: 'POST'
      }),
  // 合箱列表
  listBigExpress: (data) =>
      request({
        url: '/h5/express/listBigExpress',
        data: data,
        method: 'POST'
      }),
  // 选择合箱
  chooseBigExpress: (data) =>
      request({
        url: '/h5/express/chooseBigExpress',
        data: data,
        method: 'POST'
      }),
  // 选择合箱
  choosePinYou: (data) =>
      request({
        url: '/h5/express/choosePinYou',
        data: data,
        method: 'POST'
      }),
  // 转移包裹
  moveExpress: (data) =>
      request({
        url: '/h5/express/moveExpress',
        data: data,
        method: 'POST'
      }),
  // 转移包裹
  addExpress: (data) =>
      request({
        url: '/h5/express/newEmptyExpress',
        data: data,
        method: 'POST'
      }),
  userCouponList: (params) =>
      request({
        url: '/h5/ums/memberCoupon/list',
        method: 'GET',
        params,
      }),
  useCouponAndScore: (data) =>
      request({
        url: '/h5/express/useCouponAndScore',
        data: {
          ...data,
          realUse: false
        },
        method: 'POST'
      }),
  // 渠道列表
  channelList: (params) =>
      request({
        url: '/no-auth/home/channelList',
        params: params,
        method: 'GET',
        custom: {
          showLoading: false,
        },
    }),
  // 合并订单
  merge: (mergeOrderIdList) =>
      request({
        url: '/h5/order/merge',
        data: {mergeOrderIdList: mergeOrderIdList},
        method: 'POST'
  }),
  // 打包发货-拼邮
  batchConfirmSendType: (mergeOrderIdList, type, addressId, targetExpressNo) =>
      request({
        url: '/h5/order/batchConfirmSendType',
        data: {mergeOrderIdList: mergeOrderIdList, sendType: type, addressId: addressId, targetExpressNo: targetExpressNo, status: 0},
        method: 'POST'
      }),
  // 打包发货-直邮
  batchConfirmSendTypeForm: (form) =>
      request({
        url: '/h5/order/batchConfirmSendType',
        data: form,
        method: 'POST'
      }),
  // 外部链接
  addOrder: (form) =>
      request({
        url: '/h5/order/addOrder',
        data: form,
        method: 'POST'
      }),
  // 打包发货-拼邮-预查询
  queryBatchConfirmSendType: (mergeOrderIdList, type, addressId) =>
      request({
        url: '/h5/order/queryBatchConfirmSendType',
        data: {mergeOrderIdList: mergeOrderIdList, sendType: type, addressId: addressId, status: 0},
        method: 'POST'
      }),
  // 打包发货-直邮-预查询
  queryBatchConfirmSendTypeForm: (form) =>
      request({
        url: '/h5/order/queryBatchConfirmSendType',
        data: form,
        method: 'POST'
      }),
  // 包裹合箱
  mergeOrderExpress: (form) =>
      request({
        url: '/h5/express/mergeOrderExpress',
        data: form,
        method: 'POST'
      }),
  // 订单入库
  inStorage: (data) =>
      request({
        url: '/h5/order/inStorage',
        data: data,
        method: 'POST'
    }),
  updateStoragePicMulti: (data) =>
      request({
        url: '/h5/order/updateStoragePicMulti',
        data: data,
        method: 'POST'
      }),
  // 订单入库
  inStorageSearch: (data) =>
      request({
        url: '/h5/order/inStorageSearch',
        data: data,
        method: 'POST'
      }),
  // 订单入库
  sendTransactionsReview: (data) =>
      request({
        url: '/h5/order/sendTransactionsReview',
        data: data,
        method: 'POST'
      }),
  // 运单查询
  expressSearch: (data) =>
      request({
        url: '/h5/express/search',
        data: data,
        method: 'POST'
      }),
  // 运单拍摄
  expressUpload: (data) =>
      request({
        url: '/h5/express/upload',
        data: data,
        method: 'POST'
      }),
  // 合并订单
  reset: (orderId) =>
      request({
        url: `/h5/order/reset/${orderId}`,
        method: 'POST'
  }),
  // 评价订单
  comment: (id, data) =>
    request({
      url: 'order/order/comment/' + id,
      method: 'POST',
      data,
    }),
  // 申请退款
  applyRefund: (data) =>
    request({
      url: '/h5/order/applyRefund',
      data,
      method: 'POST',
    }),
  // 取消订单
  cancel: (data) =>
    request({
      url: '/h5/order/orderCancel',
      data,
      method: 'POST'
    }),
  // 删除订单
  delete: (id) =>
    request({
      url: 'order/order/' + id,
      method: 'DELETE',
    }),
  // 删除运费订单
  deleteExpress: (id) =>
      request({
        url: '/h5/express/' + id,
        method: 'DELETE',
      }),
  // 修改运费订单
  updateExpressStatus: (data) =>
      request({
        url: '/h5/express/updateStatus',
        method: 'POST',
        data: data
      }),
  // 售后
  aftersale: {
    // 申请售后
    apply: (data) =>
      request({
        url: 'order/aftersale',
        method: 'POST',
        data,
      }),
    list: (params) =>
      request({
        url: 'order/aftersale',
        method: 'GET',
        params,
        custom: {
          showLoading: false,
        },
      }),
    //取消售后
    cancel: (id) =>
      request({
        url: '/h5/order/cancelRefund',
        params: {orderId: id},
        method: 'GET',
      }),
    //删除售后单
    delete: (id) =>
      request({
        url: 'order/aftersale/' + id,
        method: 'DELETE',
      }),
    // 售后详情
    detail: (id) =>
      request({
        url: '/h5/order/refundOrderDetail',
        method: 'GET',
        params: {orderId: id}
      }),
  },
  //订单包裹
  express: (id, orderId) =>
    request({
      url: 'order/express/' + id + `${orderId ? '/' + orderId : ''}`,
      method: 'GET',
    }),
  count: () =>
    request({
      url: '/h5/order/countOrder',
      method: 'GET'
    })
};
